<?php
require_once(dirname(__FILE__).'/config.php');
CheckRank(0,0);
$menutype = 'mydede';
$menutype_son = 'op';
require_once(DEDEINC.'/datalistcp.class.php');
setcookie('ENV_GOBACK_URL', GetCurUrl(), time()+3600, '/');
if(!isset($dopost))
{
	$dopost = '';
}
if($dopost=='')
{
	$query = "Select * From `#@__member_convert` where mid='".$cfg_ml->M_ID."'  order by id desc";
	$dlist = new DataListCP();
	$dlist->pageSize = 20;
	$dlist->SetTemplate(DEDEMEMBER.'/templets/convert.htm');
	$dlist->SetSource($query);
	$dlist->Display();
}
elseif($dopost=='del')
{
	$ids = ereg_replace("[^0-9,]","",$ids);
	$query = "Delete From `#@__member_convert` where id in($ids) And mid='{$cfg_ml->M_ID}'";
	$dsql->ExecuteNoneQuery($query);
	ShowMsg("删除成功！","convert.php");
	exit();
}elseif($dopost=='convert')
{
	$scores = intval($scores);
	if($scores == 0){
		ShowMsg("数据错误！你输入大于0的整数！","convert.php");
		exit;
	}
	if($scores > $cfg_ml->M_Scores){
		ShowMsg("你的积分为{$cfg_ml->M_Scores}，不够{$scores}！","convert.php");
		exit;
	}
	$rmb = $scores * 0.8;
	$query1 = "Insert into `#@__member_convert` (mid,scores,rmb,apply_time) VALUES ('{$cfg_ml->M_ID}','{$scores}','$rmb','".time()."')";
	$query2 = "Update `#@__member` set scores = scores-{$scores} where mid = '{$cfg_ml->M_ID}'";
	$dsql->ExecuteNoneQuery($query1);
	$dsql->ExecuteNoneQuery($query2);
	ShowMsg("兑换成功！","convert.php");
}
?>